import { ElNotification } from "element-plus";
import { $post } from "../utils/requst";
import { $get } from "../utils/requst";

//登录
export const $Login = async (params:object)=>{
    let ret = await $post('/system/account/login',params)
    console.log(ret)
    if(ret.code == 0){
        ElNotification({
            title:'通知',
            message: ret.message,
            type:'success'
        })
        sessionStorage.setItem('account',JSON.stringify(ret.rows.accountInfo))
        sessionStorage.setItem('token',ret.rows.token)
        return ret
    }else{
        ElNotification({
            title:'通知',
            message: ret.message,
            type:'error'
        })
        return ret
    }
}

//获取控制台数据
export const $Statistics = async (params:object)=>{
    let ret = await $get('/system/user/statistics',params)
    if(ret.code == 0){
        return ret
    }else{
        ElNotification({
            title:'通知',
            message: ret.message,
            type:'error'
        })
        return ret
    }
}